home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12047 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  41 lines

  1. Path: cp.ruhr.de!Diedrich_Vorberg
  2. Date: 17 Mar 1996 02:16:00 +0200
  3. From: Diedrich_Vorberg@cp.ruhr.de (Diedrich Vorberg)
  4. Newsgroups: comp.lang.c++
  5. Message-ID: <650$zNn8XdB@cp.ruhr.de>
  6. References: <4iemrd$iap@firebrick.mindspring.com>
  7. Subject: Re: Random number question....
  8. X-Newsreader: CrossPoint v3.1
  9.  
  10. (Ryan Roberts)  hat neulich folgendes geschrieben:
  11. (Ryan Roberts)  wrote this a some time ago:
  12.  
  13. > Can some tell me how to generate _one_ random number
  14. > between 0-5 and it disaply one the string assoicated with that
  15. > random number?
  16.  
  17. Hi Ryan !
  18.  
  19. Check this out:
  20.  
  21. main()
  22. {
  23.   char String[5][100];
  24.   strcpy(String[0], "String 1"); //You might prefer to use Streams instead
  25.   strcpy(String[0], "String 1"); //But I never got used to do that ...
  26.   strcpy(String[0], "String 1");
  27.   (...)
  28.  
  29.   randomize;
  30.   n = rand() % 5;
  31.  
  32.   cout << String[n];
  33. };
  34.  
  35. Something like that ?
  36.  
  37. Hope I could help you...Diedrich :-)
  38. -- 
  39. From Diedrich_Vorberg@cp.prima.ruhr.de to you with love and in friendship
  40. FIDO: 2:2444/4538.14 Point der KASIMIR BBS +49-2330-890348
  41.